package cate.game.event.position;

import cate.common.table.d.GDFunc;
import cate.game.event.GameEventListener;
import cate.game.fight.position.PositionRule;
import cate.game.role.Role;

public class AddPositionRuleListener implements GameEventListener<AddPositionRuleEvent> {
    @Override
    public void onEvent(AddPositionRuleEvent gameEvent) {
        Role role = gameEvent.role;
        PositionRule positionRule = gameEvent.positionRule;
        if (positionRule.funcId == GDFunc.ISLAND) {
            positionRule.heroRule = role.getFarm().island.aliveHeroRule();
            positionRule.errorMsg = "阵亡英雄不可上阵";
        }else if(positionRule.funcId == GDFunc.ELITE_RACE) {
            // TODO: 2022/4/18 position check
        } else if (positionRule.funcId == GDFunc.ARENA || positionRule.funcId == GDFunc.ARENA_DEFEND) {
            positionRule.funcPositionRule = role.getPvp().arena.allowFuncPosition();
            positionRule.errorMsg = "必须上阵3队英雄";
        }else if (positionRule.funcId == GDFunc.HERO_TRAIN_CHALLENGE) {
            positionRule.funcPositionRule = role.getFarm().trainHeroFight.allowFuncPosition();
            positionRule.errorMsg = "此关卡除渡劫英雄外，只能选择一个守护者参战！";
        }
    }
}
